home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.lib;
-
- import sub_arctic.lib.sub_arctic_error;
- import sub_arctic.output.drawable;
- import sub_arctic.output.style_manager;
- import sub_arctic.constraints.std_function;
-
- import java.awt.Component;
- import java.awt.Point;
- import java.awt.Dimension;
- import java.awt.Rectangle;
- import java.awt.Image;
-
- /**
- * This class creates a fake top_level object that can be hung inside another
- * top_level object, but look to its subtree like the root. This is
- * used to place an extra level between the real top and the actual tree,
- * so that debugging lenses can be inserted without disturbing the tree.
- * This object's parent <b>must</b> be a top_level object. If it is placed
- * anywhere else, various operations will crash.<p>
- *
- * Note: this has been partially obsoleted by the new applet/frame/etc. API
- * which no longer hands out top_level objects and is set up for exactly this
- * sort of interposing above the apparent root. However, there are several
- * interactors which have not be rewritten for that, so we keep this for now.
- *
- * @author Scott Hudson
- */
- public class fake_top_level extends top_level {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set the component that this this interactor is hosted in. This gets
- * forwarded to our parent, the real root object.
- * @param Component par the hosting component
- */
- public void set_awt_parent(Component par)
- {
- if (parent() != null)
- ((top_level)parent()).set_awt_parent(par);
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the AWT component which hosts this interactor. This gets forwarded
- * to our parent, the real root object.
- * @return Component the AWT component hosting this interactor
- */
- public Component awt_parent()
- {
- if (parent() != null)
- return ((top_level)parent()).awt_parent();
- else
- return null;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct a fake top_level object hosted by the given real top_level.
- * This adds the constructed object to the given real parent and constrains
- * itself to follow the size of the parent.
- * @param top_level real_root the real root object we sit under
- */
- public fake_top_level(top_level real_root)
- {
- /* set us up at 0,0 with a temp size */
- super(0,0,10,10);
-
- /* set our parent and constrain us to its size */
- real_root.add_child(this);
- set_w_constraint(std_function.offset(PARENT.W(), 0));
- set_h_constraint(std_function.offset(PARENT.H(),0));
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Draw the image of this interactor (and its children) on the supplied
- * drawable. This reverts to normal interactor drawing behavior.
- * @param drawable parent_d the drawable to render the image on
- */
- public void draw_self(drawable parent_d)
- {
- drawable local_d;
-
- /* we would just call super.super.draw_self(), but java does not allow
- * that, so we had to copy this code from base_interactor. */
-
- /* damage will be fixed once we finish with this drawing */
- damage_fixed();
-
- /* only draw if we are visible and trivial reject test indicates it
- * might actually appear */
- if (visible() && !trivial_reject(parent_d))
- {
- /* save the graphics state and do the translation into local coords */
- local_d = enter_local_coordinates(parent_d);
-
- /* do the actual drawing */
- draw_self_local(local_d);
-
- /* restore the graphics state and undo the translation */
- exit_local_coords(parent_d, local_d);
- }
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Revert damage_self to original implementation.
- * @param Point top_left the upper left corner of the damaged area
- * @param Dimension sz the size of the damaged area
- */
- public void damage_self(Point top_left, Dimension sz)
- {
- Point parent_tl;
- interactor p;
-
- /* we would just call super.super.damage_self(), but java does not allow
- * that, so we had to copy this code from base_interactor. */
-
- /* mark us as damaged */
- set_flag_bit(DAMAGED);
-
- /* convert to parent's coords and tell them about it */
- p = parent();
- if (p != null)
- {
- /* put into coords of parent and pass damage up */
- top_left.x = top_left.x + _x;
- top_left.y = top_left.y + _y;
- p.damage_from_child(top_left,sz);
- }
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- };
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-